<template>
	<view class="border-top">
		<view class="px-2 mb-3">
			<teacher-head :info="userInfo" :school="school"></teacher-head>
		</view>
		<view class="px-25 mb-3">
			<class-card>
				<view class="flex flex-wrap">
					<view class="text-center" style="width: 25%;" v-for="(item, index) in stuList" :key="index">
						<navigator :url="item.path">
							<image :src="item.iconUrl" style="width: 104rpx;height: 104rpx;" mode=""></image>
							<view class="color333 font-weight-500 font26">{{ item.name }}</view>
						</navigator>
					</view>
				</view>
			</class-card>
		</view>
		<view class="px-25 mb-3">
			<class-card>
				<view class="flex flex-wrap">
					<view class="text-center mb-2" style="width: 25%;" v-for="(item, index) in xgList" :key="index">
						<navigator :url="item.path">
							<image :src="item.iconUrl" style="width: 104rpx;height: 104rpx;" mode=""></image>
							<view class="color333 font-weight-500 font26">{{ item.name }}</view>
						</navigator>
					</view>
				</view>
			</class-card>
		</view>
		<view class="px-25 border-top">
			<view class="p-28 color333 font30 font-weight-bold mb-2 pb-0 pt-2">教师</view>
			<view class="flex flex-wrap">
				<view class="text-center mb-1" style="width: 175rpx;" v-for="(item, index) in list" :key="index">
					<image src="../../static/img/ic_default_head.png" class="rounded-circle"
						style="width: 100rpx;height: 100rpx;"
						v-if="item.head_pic == 'http://api.sxxat.cn:443' || item.head_pic == 'http://api.sxxat.cn:443null' || item.head_pic == null|| item.head_pic == ''|| item.head_pic == 'http://localhost:8888'|| item.head_pic == 'http://localhost:8888null'|| item.head_pic == 'http://file.sxxat.cn'"
						mode=""></image>
					<image :src="item.head_pic" class="rounded-circle" style="width: 100rpx;height: 100rpx;" v-else
						mode=""></image>
					<view class="font-weight-500 font26 color666">{{ item.user_name }}</view>
				</view>
			</view>
			<!-- <view class="p-28 color333 font30 font-weight-bold mb-2 pb-0 pt-2">家长</view>
			<view class="flex flex-wrap">
				<view class="text-center mb-1" style="width: 175rpx;" v-for="(item, index) in studentlist" :key="index">
					<image src="../../static/img/ic_default_head.png" class="rounded-circle"
						style="width: 100rpx;height: 100rpx;"
						v-if="item.head_pic == 'http://api.sxxat.cn:443' || item.head_pic == 'http://api.sxxat.cn:443null' || item.head_pic == 'http://localhost:8888'|| item.head_pic == 'http://localhost:8888null'"
						mode=""></image>
					<image :src="item.head_pic" class="rounded-circle" style="width: 100rpx;height: 100rpx;" v-else
						mode=""></image>
					<view class="font-weight-500 font26 color666">{{ item.user_name }}</view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import teacherHead from '../../components/common/teacher-head.vue';
	import classCard from '../../components/common/class-card.vue';
	export default {
		data() {
			return {
				userInfo: {},
				school: '',
				stuList: [{
					name: '上课模式',
					iconUrl: '../../static/img/ic_class_mode.png',
					path: './classmode/classmode'
				}, {
					name: '学生状态',
					iconUrl: '../../static/img/ic_class_student_status.png',
					path: './studentState/studentState'
				}, {
					name: '请假',
					iconUrl: '../../static/img/ic_class_location8.png',
					path: './level/level'
				}, {
					name: '考勤',
					iconUrl: '../../static/img/ic_class_clock.png',
					path: './keep/keep'
				}],
				xgList: [{
						name: '健康功能',
						iconUrl: '../../static/img/ic_class_body.png',
						path: './health/health'
					},
					{
						name: '成绩',
						iconUrl: '../../static/img/ic_class_location4.png',
						path: './achievement/achievement'
					}, {
						name: '学习通知',
						iconUrl: '../../static/img/ic_class_location3.png',
						path: './task/task'
					}
				],
				list: [],
				studentlist: []
			};
		},
		components: {
			teacherHead,
			classCard
		},
		onLoad(options) {
			console.log(options);

			uni.getStorageSync('userInfo').class_info.forEach((item) => {
				if (item.class_id == options.classId) {
					this.userInfo = item
				}
			})
			this.getInfo(options.classId);
			uni.setStorage({
				key: 'classcode',
				data: options.id
			});
			uni.setStorage({
				key: 'class_id',
				data: options.classId
			});
			uni.setStorage({
				key: 'masterId',
				data: options.masterId
			});
		},
		methods: {
			getInfo(id) {
				let this_ = this;
				let opts = {
					url: 'SearchBj.shtml'
				};
				let param = {
					token: uni.getStorageSync('userInfo').token,
					class_id: id
				};
				this_.$http.httpRequest(opts, param).then(
					res => {
						console.log(res.data);
						if (res.data.code == '200') {
							this_.school = res.data.data.school;
							this_.list = res.data.data.teacher;
							this_.studentlist = res.data.data.student_parent
						} else {
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							});
						}
					},
					error => {
						console.log(error);
					}
				);
			}
		}
	};
</script>

<style></style>
